%!TEX program = xelatex
% 完整编译: xelatex -> biber/bibtex -> xelatex -> xelatex
\documentclass[lang=cn,11pt,a4paper]{elegantpaper}

% 本文档命令
\usepackage{array}
\usepackage{tikz}
\usepackage{pgf-pie}
\usepackage{pgfplots}
\usepackage{float}
\usepackage{amssymb}
\newcommand{\ccr}[1]{\makecell{{\color{#1}\rule{1cm}{1cm}}}}

\begin{document}

\title{Theoretical-Chapter4}

\author{周游}

\date{\zhtoday}

\maketitle


\section*{\uppercase\expandafter{\romannumeral1}}
$477_{(10)} \xrightarrow[]{FPN} (1.11011101)_2 \times 2^8$

\section*{\uppercase\expandafter{\romannumeral2}}
$\frac{3}{5} \xrightarrow[]{FPN} (1.00110011001)_2 \times 2^{-1}$

\section*{\uppercase\expandafter{\romannumeral3}}
Assume $x = 1.000\cdots 00 \times \beta ^ e $, there are p digits.
Then $x_R = 1.000\cdots 01 \times \beta ^ e $, 

$x_L = (\beta-1).(\beta-1)(\beta-1)\cdots (\beta-1)(\beta-1) \times \beta ^ {e-1} $,

$x_R-x = \beta^{e-p} $, $x - x_L = \beta^{e-1-p} $, so $x_R-x=\beta(x-x_L)$ . 

\section*{\uppercase\expandafter{\romannumeral4}}
There are 23 digits after dot. $x = \frac{3}{5}$.

$x_L = 1.00110011001100110011001 \times 2^{-1} $

\ \ $x = 1.001100110011001100110011001\cdots \times 2^{-1} $

$x_R = 1.00110011001100110011010 \times 2^{-1} $

$fl(x) = x_R$,  

$x-x_L = \frac{3}{5} \times 2^{-24}$

$x_R-x_L =  2^{-24}$

absolute error = $|fl(x) - x| = x_R-x = \frac{2}{5} \times 2^{-24}$

relative roundoff error = $\frac{|fl(x) - x|}{|x|} = \frac{2}{3} \times 2^{-24}$

\section*{\uppercase\expandafter{\romannumeral5}}
由于$fl(x)-x$可以无限接近$\epsilon _M$, 
$|fl(x)-x|<|x_R-x_L|\leqslant \epsilon_M|x| $,
$\epsilon _u = \epsilon _M = 2^{-23} $

\section*{\uppercase\expandafter{\romannumeral6}}
$\cos(0.25) \approx (0.9689124217106447)_{10}  \approx (1.111100000001\cdots)_2 \times 2^{-1} $

$1 = 1 \times 2^{0} $

$1-\cos(0.25) = (0.0000011111\cdots)_2  \times 2^{0} = (1.1111\cdots)_2  \times 2^{-6}$, 6 bits are lost.

\section*{\uppercase\expandafter{\romannumeral7}}
避免两个相近的数的相减:

  (1) $1 - \cos(x) = 2 sin^2(\frac{x}{2}) $

  (2) $1 - \cos(x) = \frac{x^2}{2!} - \frac{x^4}{4!} + \cdots $


\section*{\uppercase\expandafter{\romannumeral8}}
\begin{itemize}
    \item 
    $f(x) = (x-1)^\alpha,  C_f(x) = |\frac{\alpha x}{x-1} | $ , it's large when $\alpha \neq 0, x \rightarrow 1 $
    \item 
    $f(x) = \ln x, C_f(x) = \frac{1}{|\ln x|} $, it's large when $ x \rightarrow 1 $
    \item 
    $f(x) = e^ x, C_f(x) = |x| $, it's large when $ x \rightarrow \infty $
    \item 
    $f(x) = \arccos x, C_f(x) = |\frac{x}{\sqrt{1-x^2}\arccos(x) }| $, it's large when $ |x| \rightarrow 1 $
  \end{itemize}

\section*{\uppercase\expandafter{\romannumeral9}}
\begin{itemize}
    \item 
    $For\ x \in [0.1], C_f(x) = \frac{x}{e^x-1} , C_f'(x) = \frac{(e^x-1)(1-x)}{(e^x-1)^2} \geqslant 0 $\\
    since $C_f(1) = \frac{1}{e-1} < 1 $, so $C_f(x) \leqslant 1$
    \item 
    $cond_A(x) = \frac{1}{\epsilon_u} \inf \limits_{\{x_A\}} |\frac{x_A-x}{x}| $ \\
    $1 - e^{-x_A} = (1+\delta _1)[1-(1+\delta_2 )e^{-(1+\delta_3)x}]$, 其中 $|\delta_i| < \epsilon_u$ 忽略$O(\delta_i^2)$ 化简得\\
    $|x_A - x| = |- \ln (1+\delta)(1+2\delta+\delta x)| \approx 3\delta + \delta x $ , and $|\delta| < \epsilon_u$ \\
    So $cond_A(x) \leqslant \frac{3+x}{x}$, hence A is well conditioned except when $x \rightarrow 0^+$.
    \hspace*{\fill} 
    \item
    $cond_f(x)$ is low at $\forall$ x $\in$ [0,1] and $cond_A(x)$ is also low except when $x \rightarrow 0^+$, it becomes large.\\
    x趋于0时不满足$C_f(x)$非零有界的条件，故不满足Thm4.76的条件，与Thm4.76的结论相背。
\end{itemize}

\begin{figure}[H]
    \centering
    \includegraphics[width=0.3\textwidth]{figure2.png}
    \caption{$cond_A(x)\ and\ cond_f(x)$}
\end{figure}

\section*{\uppercase\expandafter{\romannumeral10}}
By Def 4.68, the componentwise condition : 

$cond_f(x) = \sum\limits_{k=0}^{n-1}|\frac{a_k}{r}\frac{\partial f}{\partial a_k }|$

对 $r^n + a_{n-1} + \cdots + a_0 = 0$ , 两端对 $a_k$ 求导，

$r^k + \frac{\partial f}{\partial a_k}q'(r) = 0$ , so $\frac{\partial f}{\partial a_k} = - \frac{r^k}{q'(r)}$

$cond_f(x) = \sum\limits_{k=0}^{n-1}|\frac{a_kr^k}{rq'(r)}| = |\frac{r^{n-1}}{q'(r)} |$

consider Wilkinson example, $cond_f(x) = \frac{r^{n-1}}{f'(r)} $, n 大时条件数会很大。

\section*{\uppercase\expandafter{\romannumeral11}}
考虑 2p = 4, a = 1.000 , b = 1.100 , a/b = 0.101 = 1.01 $\times 2^{-1}$ . 

相对误差 err = $\frac{\frac{10}{11}-0.101}{\frac{10}{11}}$ = 0.45 

而 $\epsilon_u$ = $\frac{1}{2} 2^{1-2}$ = 0.25 < 0.45 , contradict.

\section*{\uppercase\expandafter{\romannumeral12}}
128 = 1 $\times$ $2^7$ , 129 = 1.0000001 $\times$ $2^7$

相邻浮点数间距 $d = 2^{1-24} * 2^7 = 2^{-16} > 10^{-6}$ , 故不能精确到 $10^{-6}$

\section*{\uppercase\expandafter{\romannumeral13}}
设两节点 $x_k , x_{k+1}$ 相距较近，在$[x_k,x_{k+}]$上，

$s(x) = f_i + m_i(x-x_i) + c(x-x_i)^2 + d(x-x_i)^3$ , 求c,d,需要求A的逆

\begin{equation*}
A = \left(
  \begin{aligned}
      (x_{i+1} - x_i)^2 &  (x_{i+1} - x_i)^3  \\
      2(x_{i+1} - x_i) &  3(x_{i+1} - x_i)^2   \\
   \end{aligned}       
\right)
\end{equation*}

由于$x_k , x_{k+1}$ 相距较近，A是近似奇异矩阵。gets inaccurate results.

\end{document} 